/******************************************************************************
 * * desktop_status_bar.c - implementation of status bar functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "desktop_global.h"


/**
 * Get battery level
 * param (in) Bat: UINT8
 * return  UINT8
 */
UINT8 Framework_Get_Battery_Level(UINT8 Bat)
{
    if (FRAMEWORK_LOWER_LIMIT_FOR_BATTERY_4 < Bat)
    {
        return(HAL_BAT_FULL);
    }
    else if (FRAMEWORK_LOWER_LIMIT_FOR_BATTERY_3 < Bat)
    {
        return(HAL_BAT_HIGH);
    }
    else if (FRAMEWORK_LOWER_LIMIT_FOR_BATTERY_2 < Bat)
    {
        return(HAL_BAT_NORMAL);
    }
    else if (FRAMEWORK_LOWER_LIMIT_FOR_BATTERY_1 < Bat)
    {
        return(HAL_BAT_LOW);
    }
    else
    {
        return(HAL_BAT_EMPTY);
    }
}


/**
 * Get symbol for battery
 * param (in) BatSta: HAL_BAT_STATUS
 * return  INT8 *
 */
INT8 *Framework_Get_Battery_Symbol(UINT8 BatSta)
{
    if (HAL_BAT_EMPTY == BatSta)
    {
        return(LV_SYMBOL_BATTERY_EMPTY);
    }
    else if (HAL_BAT_LOW == BatSta)
    {
        return(LV_SYMBOL_BATTERY_1);
    }
    else if (HAL_BAT_NORMAL == BatSta)
    {
        return(LV_SYMBOL_BATTERY_2);
    }
    else if (HAL_BAT_HIGH == BatSta)
    {
        return(LV_SYMBOL_BATTERY_3);
    }
    else if (HAL_BAT_FULL == BatSta)
    {
        return(LV_SYMBOL_BATTERY_FULL);
    }
    else
    {
        /* error */
        return(LV_SYMBOL_BATTERY_EMPTY);
    }
}


/**
 * Update battery every second
 * param (in) VOID
 * return  VOID
 */
VOID Framework_Update_Battery_Status(VOID)
{
    INT8                       *BatSymbol;
    UI_FullScreen_Label_Desc_t *FullScrnLblDesc;
    UINT8                      OldStatus = g_FrameworkMng.BatteryStatus;
    UINT8                      Status = Framework_Get_Battery_Level(Hal_Battery_Get_Status());
    if (Status != g_FrameworkMng.BatteryStatus)
    {
        g_FrameworkMng.BatteryStatus = Status;

        BatSymbol = Framework_Get_Battery_Symbol(Status);

        if (ACT_ID_CHARGE_ANIMATION == Nav_Get_Top())
        {
            FullScrnLblDesc = (UI_FullScreen_Label_Desc_t *)Nav_Get_Param(ACT_ID_CHARGE_ANIMATION);
            lv_label_set_text(FullScrnLblDesc->BatteryLabel.Label, BatSymbol);

            if (TRUE == g_FrameworkMng.ChargeFlg)
            {
                if (HAL_BAT_FULL != OldStatus)
                {
                    lv_anim_del(FullScrnLblDesc->BatteryLabel.Label, Framework_Charging_Anim);

                    if (HAL_BAT_FULL != g_FrameworkMng.BatteryStatus)
                    {
                        Framework_Play_Charging_Anim(FullScrnLblDesc->BatteryLabel.Label);
                    }
                }
            }
        }
        else
        {
            if (NULL != g_FrameworkMng.LabelBattery)
            {
                lv_label_set_text(g_FrameworkMng.LabelBattery, BatSymbol);

                if (TRUE == g_FrameworkMng.ChargeFlg)
                {
                    if (HAL_BAT_FULL != OldStatus)
                    {
                        lv_anim_del(g_FrameworkMng.LabelBattery,Framework_Charging_Anim);

                        if (HAL_BAT_FULL != g_FrameworkMng.BatteryStatus)
                        {
                            Framework_Play_Charging_Anim(g_FrameworkMng.LabelBattery);
                        }
                    }
                }
            }
        }
    }
} /* Hal_Battery_Status_Ind */


/**
 * Update charging status every second
 * param (in) VOID
 * return  VOID
 */
VOID Framework_Update_Charger_Status(VOID *Para)
{
    UINT32 Status = (UINT32)Para;

    if (HAL_CHG_DISCONNECTED == (HAL_CHG_STATUS)Status)
    {
        if (TRUE == g_FrameworkMng.ChargeFlg)
        {
            g_FrameworkMng.ChargeFlg = FALSE;

            if (ACT_ID_CHARGE_ANIMATION == Nav_Get_Top())
            {
                Framework_Set_Lcd_Status(FALSE);
                if (g_FrameworkMng.Task)
                {
                    lv_task_set_prio(g_FrameworkMng.Task, LV_TASK_PRIO_OFF);
                }
                Framework_Set_Phone_Ready_Status(FALSE);
                Hal_Power_Off(HAL_TYPE_POWER_OFF);
            }
            else
            {
                if (NULL != g_FrameworkMng.LabelBattery)
                {
                    /* lv_label_set_text(g_FrameworkMng.StatusBar.Label_Charge, ""); */

                    if (HAL_BAT_FULL != g_FrameworkMng.BatteryStatus)
                    {
                        lv_anim_del(g_FrameworkMng.LabelBattery,Framework_Charging_Anim);
                        g_FrameworkMng.BatteryStatus = Framework_Get_Battery_Level(Hal_Battery_Get_Status());
                        lv_label_set_text(g_FrameworkMng.LabelBattery,
                                          Framework_Get_Battery_Symbol(g_FrameworkMng.BatteryStatus));
                    }
                }
            }
        }
    }
    else if (HAL_CHG_CONNECTED == (HAL_CHG_STATUS)Status)
    {
        if (FALSE == g_FrameworkMng.ChargeFlg)
        {
            g_FrameworkMng.ChargeFlg = TRUE;

            if (NULL != g_FrameworkMng.LabelBattery)
            {
                /* lv_label_set_text(g_FrameworkMng.StatusBar.Label_Charge, LV_SYMBOL_CHARGE); */

                if (HAL_BAT_FULL == g_FrameworkMng.BatteryStatus)
                {
                    UI_Log_Out(UI_SUB_MODULE_FRAMEWORK, UI_LOG_LEVEL_TRACE_2,
                        "Hal_Charger_Status_Ind, battery full\n");
                    return;
                }

                Framework_Play_Charging_Anim(g_FrameworkMng.LabelBattery);
            }
        }
    }
    else
    {
        /* error */
    }
}


/**
 * Get symbol from signal
 * param (in) Bar: MMI_MODEM_SIGNAL_BAR
 * return  INT8 *
 */
INT8 *Framework_Signal_Bar_To_Symbol(MMI_MODEM_SIGNAL_BAR Bar)
{
    switch (Bar)
    {
    case MMI_MODEM_SIGNAL_BAR_0:
        return SYMBOL_SIGNAL_0;

    case MMI_MODEM_SIGNAL_BAR_1:
        return SYMBOL_SIGNAL_1;

    case MMI_MODEM_SIGNAL_BAR_2:
        return SYMBOL_SIGNAL_2;

    case MMI_MODEM_SIGNAL_BAR_3:
        return SYMBOL_SIGNAL_3;

    case MMI_MODEM_SIGNAL_BAR_4:
        return SYMBOL_SIGNAL_4;

    case MMI_MODEM_SIGNAL_BAR_5:
        return SYMBOL_SIGNAL_5;

    default:
        /* error */
        return SYMBOL_SIGNAL_0;
    }
}


/**
 * Add symbol to status bar
 * param (in) Symbol: INT8 *, path for symbol image
 * param (in) MaxW: lv_coord_t *
 * param (in) Child: lv_obj_t **
 * return  BOOL: falure if FALSE
 */
BOOL Framework_Add_Status_Symbol(const INT8 *Symbol, lv_coord_t *MaxW, lv_obj_t **Child)
{
    lv_img_header_t ImgHeader;
    lv_coord_t      PadHor;
    lv_obj_t        *ChildPrev = *Child;

    if (NULL == *Child)
    {
        PadHor = 0;
    }
    else
    {
        PadHor = 2;
    }

    lv_img_decoder_get_info(Symbol, &ImgHeader);
    ImgHeader.w += PadHor;
    if (*MaxW < ImgHeader.w)
    {
        return FALSE;
    }

    *MaxW -= ImgHeader.w;

    *Child = lv_obj_get_child_back(g_FrameworkMng.ContStatus, *Child);
    if (NULL == *Child)
    {
        *Child = lv_img_create(g_FrameworkMng.ContStatus, NULL);
    }
    lv_img_set_src(*Child, Symbol);
    if (NULL == ChildPrev)
    {
        lv_obj_align(*Child, g_FrameworkMng.ContStatus, LV_ALIGN_IN_RIGHT_MID, 0, 0);
    }
    else
    {
        lv_obj_align(*Child, ChildPrev, LV_ALIGN_OUT_LEFT_MID, -PadHor, 0);
    }

    return TRUE;
}


/**
 * Sort and display symbols in status bar
 * param (in) Update: FRAMEWORK_STA_BAR_UPDATE
 * return  VOID
 */
VOID Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE Update)
{
    lv_obj_t   *Child = NULL;
    lv_obj_t   *ChildNext;
    lv_coord_t MaxW;

    if (NULL == g_FrameworkMng.ContStatus)
    {
        /* error */
        return;
    }

    if (IF_FRAMEWORK_INIT_CHARGE == g_FrameworkMng.PowerOnType)
    {
        return;
    }

    if ((FRAMEWORK_STA_BAR_UPDATE_SIGNAL == Update)
        || (FRAMEWORK_STA_BAR_UPDATE_ALL == Update))
    {
        if (TRUE == g_FrameworkMng.FlightModeOn)
        {
            lv_img_set_src(g_FrameworkMng.ImgSimSta[0], SYMBOL_FLIGHT_MODE);
            lv_obj_set_hidden(g_FrameworkMng.ImgSimSta[1], TRUE);
            return;
        }

        if (FRAMEWORK_SIM_STATUS_PRESENT != g_FrameworkMng.SimStatus[0])
        {
            lv_img_set_src(g_FrameworkMng.ImgSimSta[0], SYMBOL_NO_SIM_CARD);
        }
        else
        {
            lv_img_set_src(g_FrameworkMng.ImgSimSta[0],
                           Framework_Signal_Bar_To_Symbol(g_FrameworkMng.SignalBar[0]));
        }

        if (lv_obj_get_hidden(g_FrameworkMng.ImgSimSta[1]))
        {
            lv_obj_set_hidden(g_FrameworkMng.ImgSimSta[1], FALSE);
        }
        if (FRAMEWORK_SIM_STATUS_PRESENT != g_FrameworkMng.SimStatus[1])
        {
            lv_img_set_src(g_FrameworkMng.ImgSimSta[1], SYMBOL_NO_SIM_CARD);
        }
        else
        {
            lv_img_set_src(g_FrameworkMng.ImgSimSta[1],
                           Framework_Signal_Bar_To_Symbol(g_FrameworkMng.SignalBar[1]));
        }
    }

    if ((FRAMEWORK_STA_BAR_UPDATE_OTHERS == Update)
        || (FRAMEWORK_STA_BAR_UPDATE_ALL == Update))
    {
        MaxW = lv_obj_get_width_fit(g_FrameworkMng.ContStatus);

#if USE_LV_WLAN != 0
        if (0 < g_FrameworkMng.WifiLevel)
        {
            const VOID *WifiSignalImg[] = {NULL, SYMBOL_WIFI_LOW, SYMBOL_WIFI_MID, SYMBOL_WIFI_HIGH,
                                           SYMBOL_WIFI_FULL};
            if (FALSE == Framework_Add_Status_Symbol(WifiSignalImg[g_FrameworkMng.WifiLevel],
                                                     &MaxW, &Child))
            {
                return;
            }
        }
#endif

        if (TRUE == g_FrameworkMng.AlarmFlg)
        {
            if (FALSE == Framework_Add_Status_Symbol(SYMBOL_ALARM, &MaxW, &Child))
            {
                return;
            }
        }

        if (TRUE == g_FrameworkMng.SilenceFlg)
        {
            if (FALSE == Framework_Add_Status_Symbol(SYMBOL_VOLUME_MUTED, &MaxW, &Child))
            {
                return;
            }
        }

        if (TRUE == g_FrameworkMng.CallingFlg)
        {   /* in a call */
            if (FALSE == Framework_Add_Status_Symbol(SYMBOL_CALL_PHONE, &MaxW, &Child))
            {
                return;
            }

            if (TRUE == g_FrameworkMng.LoudspeakerFlg)
            {
                if (FALSE == Framework_Add_Status_Symbol(SYMBOL_SPEAKER_LOUDER, &MaxW, &Child))
                {
                    return;
                }
            }
        }

        if (TRUE == g_FrameworkMng.UnreadMissedCallFlg)
        {
            if (FALSE == Framework_Add_Status_Symbol(SYMBOL_CALL_MISSED, &MaxW, &Child))
            {
                return;
            }
        }

        if (TRUE == g_FrameworkMng.UnreadSmsFlg)
        {
            if (FALSE == Framework_Add_Status_Symbol(SYMBOL_UNREAD_SMS, &MaxW, &Child))
            {
                return;
            }
        }

        Child = lv_obj_get_child_back(g_FrameworkMng.ContStatus, Child);
        while (Child)
        {
            ChildNext = lv_obj_get_child_back(g_FrameworkMng.ContStatus, Child);
            lv_obj_del(Child);
            Child = ChildNext;
        }
    }
} /* Framework_Status_Bar_Sort */


/**
 * Update signal bar
 * param (in) SimId: MMI_MODEM_SIM_ID
 * param (in) Bar: MMI_MODEM_SIGNAL_BAR
 * return  VOID
 */
VOID Framework_Update_Signal_Bar(VOID)
{
    MMI_MODEM_SIGNAL_BAR SignalBar1 = g_FrameworkMng.SignalBar[MMI_MODEM_SIM_1];
    MMI_MODEM_SIGNAL_BAR SignalBar2 = g_FrameworkMng.SignalBar[MMI_MODEM_SIM_2];

    g_FrameworkMng.SignalBar[MMI_MODEM_SIM_1] = MMI_Modem_Get_Signal_Bar_Req(MMI_MODEM_SIM_1);
    g_FrameworkMng.SignalBar[MMI_MODEM_SIM_2] = MMI_Modem_Get_Signal_Bar_Req(MMI_MODEM_SIM_2);

    if ((SignalBar1 != g_FrameworkMng.SignalBar[MMI_MODEM_SIM_1])
        || (SignalBar2 != g_FrameworkMng.SignalBar[MMI_MODEM_SIM_2]))
    {
        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_SIGNAL);
    }
}


/**
 * Update the current time and date every second
 * param (in) VOID
 * return  VOID
 */
VOID Framework_Update_Time_And_Date(VOID)
{
    INT8        TimeStr[13] = { 0 };
    INT8        DateStr[11] = { 0 };
    const INT8  *Time;
    const INT8  *Date;
    lv_obj_t    *Label_Time;
    lv_obj_t    *Label_Date;
    hal_rtc_t   TimeAndDate;
    ACTIVITY_ID TopActId;
    VOID        *Param;

    if (FRAMEWORK_TIME_HIDE == g_FrameworkMng.TimeFormat.TimeDisplay)
    {
        return;
    }

    TopActId = Nav_Get_Top();
    if (ACT_ID_DESKTOP == TopActId)
    {
        Param = Nav_Get_Param(TopActId);
        Label_Time = ((UI_Desktop_Desc_t *)Param)->ContLabel[0].Label;
        Label_Date = ((UI_Desktop_Desc_t *)Param)->ContLabel[1].Label;
    }
    else if (ACT_ID_DESKTOP_UNLOCK == TopActId)
    {
        Param = Nav_Get_Param(TopActId);
        Label_Time = ((UI_Desktop_Unlock_Desc_t *)Param)->ContLabel[0].Label;
        Label_Date = ((UI_Desktop_Unlock_Desc_t *)Param)->ContLabel[1].Label;
    }
    else if (ACT_ID_KEY_GUARD == TopActId)
    {
        Param = Nav_Get_Param(TopActId);
        Label_Time = ((UI_FullScreen_Key_Guard_Desc_t *)Param)->TimeLabel.Label;
        Label_Date = ((UI_FullScreen_Key_Guard_Desc_t *)Param)->DateLabel.Label;
    }
    else
    {
        return;
    }

    Hal_Rtc_Gettime(&TimeAndDate);
    Framework_Change_Time_And_Date_To_String(&TimeAndDate, TimeStr, DateStr);

    Time = lv_label_get_text(Label_Time);
    Date = lv_label_get_text(Label_Date);

    if (0 != strcmp(TimeStr, Time))
    {
        lv_label_set_text(Label_Time, TimeStr);
    }

    if (0 != strcmp(DateStr, Date))
    {
        lv_label_set_text(Label_Date, DateStr);
    }
}


#if USE_LV_WLAN != 0

/**
 * Update wifi status
 * param (in) VOID
 * return  VOID
 */
VOID Framework_Update_Wifi_Status(VOID)
{
    UINT8 Power = hal_wlan_get_act_ap_power();
    UINT8 Level = 0;
    if (0 < Power)
    {
        if(HAL_WLAN_SIGNAL_STRENGTH_EXCELLENT < Power) {
            Level = 4;
        } else if(HAL_WLAN_SIGNAL_STRENGTH_GOOD < Power) {
            Level = 3;
        } else if(HAL_WLAN_SIGNAL_STRENGTH_FAIR < Power) {
            Level = 2;
        } else if(HAL_WLAN_SIGNAL_STRENGTH_POOR < Power) {
            Level = 1;
        }
    }
    if (g_FrameworkMng.WifiLevel != Level)
    {
        g_FrameworkMng.WifiLevel = Level;
        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
    }
}
#endif


/**
 * update time and date, battery status, charger status, signal bar
 * param (in) UpdateSignal: BOOL, TRUE if need to update signal bar
 * return  VOID
 */
VOID Framework_Update_Status(BOOL UpdateSignal)
{
    Framework_Update_Time_And_Date();
    Framework_Update_Battery_Status();
    if (TRUE == UpdateSignal)
    {
        Framework_Update_Signal_Bar();
    }
#if USE_LV_WLAN != 0
    Framework_Update_Wifi_Status();
#endif
}


/**
 * update battery and charger status during power off
 * param (in) VOID
 * return  VOID
 */
VOID Framework_PowerOff_Update_Status(VOID)
{
    Framework_Update_Battery_Status();
}


/**
 * Create Status bar
 * param (in) VOID
 * return  VOID
 */
VOID Framework_Create_Status_Bar(VOID)
{
    UI_Status_Bar_Desc_t StaBarDesc;

    if ((NULL != g_FrameworkMng.ContStatus)
        || (NULL != g_FrameworkMng.LabelBattery))
    {
        return;
    }

    Hal_Mem_Set(&StaBarDesc, 0, sizeof(UI_Status_Bar_Desc_t));
    StaBarDesc.BatteryLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    StaBarDesc.BatteryLabel.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    StaBarDesc.BatteryLabel.LabelAlign = LV_ALIGN_IN_RIGHT_MID;
    g_FrameworkMng.BatteryStatus       = Framework_Get_Battery_Level(Hal_Battery_Get_Status());
    StaBarDesc.BatteryLabel.SymbolId   = Framework_Get_Battery_Symbol(g_FrameworkMng.BatteryStatus);

    UI_Status_Bar_Create(&StaBarDesc);

    g_FrameworkMng.ImgSimSta[0] = StaBarDesc.SimImg[0].Img;
    g_FrameworkMng.ImgSimSta[1] = StaBarDesc.SimImg[1].Img;
    g_FrameworkMng.ContStatus   = StaBarDesc.StatusCont.Container;
    g_FrameworkMng.LabelBattery = StaBarDesc.BatteryLabel.Label;

    Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_ALL);

    if (TRUE == g_FrameworkMng.ChargeFlg)
    {
        if (HAL_BAT_FULL != g_FrameworkMng.BatteryStatus)
        {
            Framework_Play_Charging_Anim(g_FrameworkMng.LabelBattery);
        }
    }
} /* Framework_Create_Status_Bar */


/**
 * Display status bar
 * param (in) DisplaySignal: BOOL
 * return VOID
 */
VOID Framework_Display_Status_Bar(BOOL DisplaySignal)
{
    Framework_Create_Status_Bar();
    if (FALSE == DisplaySignal)
    {
        lv_obj_set_hidden(g_FrameworkMng.ImgSimSta[0], TRUE);
        lv_obj_set_hidden(g_FrameworkMng.ImgSimSta[1], TRUE);
    }
}


/**
 * Function for charging animation
 * param (in) Label: VOID *
 * param (in) Value: lv_anim_value_t
 * return  VOID
 */
VOID Framework_Charging_Anim(VOID *Label, lv_anim_value_t Value)
{
    lv_label_set_text(Label, Framework_Get_Battery_Symbol(Value));
}


/**
 * Play charging animatin
 * param (in) Label_Bettery: lv_obj_t *
 * return  VOID
 */
VOID Framework_Play_Charging_Anim(lv_obj_t *Label_Battery)
{
    lv_anim_t Anim;
    lv_anim_init(&Anim);
    lv_anim_set_var(&Anim, Label_Battery);
    lv_anim_set_values(&Anim, g_FrameworkMng.BatteryStatus, HAL_BAT_FULL);
    lv_anim_set_exec_cb(&Anim, Framework_Charging_Anim);
    lv_anim_set_time(&Anim, 1000);
    lv_anim_set_repeat_count(&Anim, LV_ANIM_REPEAT_INFINITE);
    lv_anim_set_repeat_delay(&Anim, 400);
    lv_anim_start(&Anim);
}


/**
 * Alarm setting indicator from alarm module
 * param (in) OnOff: BOOL
 * return  VOID
 */
VOID Framework_Alarm_Set_Alarm_Ind(BOOL OnOff)
{
    if (OnOff != g_FrameworkMng.AlarmFlg)
    {
        g_FrameworkMng.AlarmFlg = OnOff;
        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
    }
}


/**
 * Silence indicator from setting module
 * param (in) Silent: BOOL
 * return  VOID
 */
VOID Setting_Ring_Silent_Ind(BOOL Silent)
{
    if (Silent != g_FrameworkMng.SilenceFlg)
    {
        g_FrameworkMng.SilenceFlg = Silent;
        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
    }
}


/**
 * Call beginning or end indicator from call module
 * param (in) Call: BOOL
 * param (in) MissedCall: BOOL
 * return  VOID
 */
VOID Framework_Call_Calling_Or_Incoming_Ind(BOOL Call, BOOL MissedCall)
{
    if (Call != g_FrameworkMng.CallingFlg)
    {
        g_FrameworkMng.CallingFlg = Call;

        if (FALSE == Call)
        {
            g_FrameworkMng.LoudspeakerFlg = FALSE;
        }

        if (TRUE == MissedCall)
        {
            g_FrameworkMng.UnreadMissedCallFlg = TRUE;
            g_FrameworkMng.UnreadMissedCallNum++;
        }

        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
    }
}


/**
 * Loudspeaker on or off indicator from call module
 * param (in) Loudspeaker: BOOL
 * return  VOID
 */
VOID Framework_Call_Loudspeaker_Ind(BOOL Loudspeaker)
{
    if (Loudspeaker != g_FrameworkMng.LoudspeakerFlg)
    {
        g_FrameworkMng.LoudspeakerFlg = Loudspeaker;

        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
    }
}


/**
 * Missed call read indicator from call log module
 * param (in) VOID
 * return  VOID
 */
VOID Framework_CallLog_Missed_Call_Read_Ind(VOID)
{
    if (TRUE == g_FrameworkMng.UnreadMissedCallFlg)
    {
        g_FrameworkMng.UnreadMissedCallFlg = FALSE;
        g_FrameworkMng.UnreadMissedCallNum = 0;
        Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
    }
}


/**
 * Unread SMS indicator from SMS module
 * param (in) Count: UINT8
 * return  VOID
 */
VOID Framework_Sms_Unread_Message_Ind(UINT8 Count)
{
    g_FrameworkMng.UnreadSmsNum = Count;

    if (0 == Count)
    {
        if (TRUE == g_FrameworkMng.UnreadSmsFlg)
        {
            g_FrameworkMng.UnreadSmsFlg = FALSE;

            Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
        }
    }
    else
    {
        if (FALSE == g_FrameworkMng.UnreadSmsFlg)
        {
            g_FrameworkMng.UnreadSmsFlg = TRUE;

            Framework_Status_Bar_Sort(FRAMEWORK_STA_BAR_UPDATE_OTHERS);
        }

        if (ACT_ID_DESKTOP == Nav_Get_Top())
        {
            Framework_Create_Desktop_Unread_Sms();
        }
        else if (ACT_ID_KEY_GUARD == Nav_Get_Top())
        {
            Framework_Create_Desktop_Unlock();
        }
        else if (ACT_ID_DESKTOP_UNREAD_SMS == Nav_Get_Top())
        {
            Nav_Back(ACT_ID_DESKTOP_UNREAD_SMS);
            Framework_Create_Desktop_Unread_Sms();
        }
    }
}
